//
//  ClassifiedDetailsViewController.m
//  时尚男士
//
//  Created by dllo on 15/6/5.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ClassifiedDetailsViewController.h"
#import "MainDetailedPageViewController.h"
#import "ClassificationViewController.h"
#define Width self.view.frame.size.width / 4
#define Height  self.view.frame.size.height
@interface ClassifiedDetailsViewController ()<UIScrollViewDelegate>
@property (nonatomic, retain)NSMutableArray *sourceArr;
@property (nonatomic ,retain)UIScrollView *scrollView;
@property (nonatomic, assign)int a;
@property (nonatomic, retain) NSArray *myarr;
@property (nonatomic, retain) NSMutableArray *buttonArr;
@property (nonatomic, assign) int buttonNumber;
@property (nonatomic, retain)NSMutableArray *imageName;
@property (nonatomic, retain)NSMutableArray *urlArr;
@end

@implementation ClassifiedDetailsViewController
- (void)dealloc{
    [super dealloc];
    [_sourceArr release];
    [_scrollView release];
    [_myarr release];
    [_buttonArr release];
    [_imageName release];
    [_urlArr release];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.hud hide:YES];
    self.imageName = [NSMutableArray array];
    self.buttonArr = [NSMutableArray array];
    self.sourceArr = [[NSMutableArray alloc] init];
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    self.scrollView.delegate = self;
    [self.view addSubview:self.scrollView];
    self.scrollView.contentSize = CGSizeMake(0, Height + 40);
    [self.scrollView release];
    self.imageName = [NSMutableArray arrayWithObjects:@"chuanda.jpg",@"dushi.jpg",@"fugu.jpg",@"peise.jpg",@"qingchun.jpg",@"rihan.jpg",@"shangwu.jpg",@"shejishi.jpg",@"xiaoqingxin.jpg",@"xiuxian.jpg",@"yinglun.jpeg",@"yundong.jpg", nil];
    [self myLayOutView];
    [_imageName release];
    NSString *str1 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E7%A9%BF%E6%90%AD&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561541%20md5_1b%20t_1432890077&width=320&keyword=";
    NSString *str2 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E9%83%BD%E5%B8%82&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561326%20md5_73%20t_1432890077&width=320&keyword=";
    NSString *str3 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E5%A4%8D%E5%8F%A4&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561684%20md5_a4%20t_1432890077&width=320&keyword=";
    NSString *str4 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E9%85%8D%E8%89%B2&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561578%20md5_e3%20t_1432890077&width=320&keyword=";
    NSString *str5 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E9%9D%92%E6%98%A5&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561217%20md5_4c%20t_1432890077&width=320&keyword=";
    NSString *str6 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E6%97%A5%E9%9F%A9&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561713%20md5_b3%20t_1432890077&width=320&keyword=";
    NSString *str7 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E5%95%86%E5%8A%A1&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561404%20md5_27%20t_1432890077&width=320&keyword=";
    NSString *str8 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E8%AE%BE%E8%AE%A1%E5%B8%88&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561743%20md5_02%20t_1432890077&width=320&keyword=";
    NSString *str9 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E5%B0%8F%E6%B8%85%E6%96%B0&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561765%20md5_88%20t_1432890077&width=320&keyword=";
    NSString *str10 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E4%BC%91%E9%97%B2&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561380%20md5_e7%20t_1432890077&width=320&keyword=";
    NSString *str11 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E6%83%85%E4%BE%A3&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433561612%20md5_5b%20t_1432890077&width=320&keyword=";
    NSString *str12 = @"http://rm.app.isee.com.cn/json_rm.php?action=list&ver=10&page=0&category=nanren&category2=%2F%E8%BF%90%E5%8A%A8&pageSize=24&appCookie=channel_AppStore%20version_6.6%20oid_9342E03B-D33F-4832-B1A0-037604E0A97E%20package_com.aslibra.rm.nanren%20platform_iphone%20ver_7.1.2%20jb_1%20t1_1433582230%20md5_fd%20t_1432890077&width=320&keyword=";
    self.urlArr = [NSMutableArray arrayWithObjects:str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11,str12, nil];
}

- (void)myLayOutView{
    self.a = 0;
    self. myarr = [NSArray arrayWithObjects:@"穿搭",@"都市",@"复古", @"配色",@"青春",@"日韩",@"商务",@"设计师",@"小清新",@"休闲",@"英伦",@"运动",nil];
    for (int j = 0;  j< 3; j ++) {
        for (int i = 0; i < 4; i ++) {
            UIButton *mybutton = [UIButton buttonWithType:UIButtonTypeSystem];
            NSString *str = [self.imageName objectAtIndex:self.a];
            [mybutton setBackgroundImage:[UIImage imageNamed:str] forState:UIControlStateNormal];
            mybutton.frame = CGRectMake(10 + Width * j + j * 30  , 10 + Width * i + 40 * i, Width , Width );
            mybutton.layer.cornerRadius = Width / 2;
            mybutton.clipsToBounds = YES;
            
            [self.scrollView addSubview:mybutton];
            [self.buttonArr addObject:mybutton];
            [mybutton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
            
            
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10 + Width * j + j * 30, 10 + Width *(i + 1) + 40 * i, Width, 20)];
            [self.scrollView addSubview:label];
            
            label.textAlignment = NSTextAlignmentCenter;
            label.text = [self.myarr objectAtIndex:self.a];
            self.a = self.a + 1;
            [label release];
    }
    }
        [_urlArr release];
    [_myarr release];
}

- (void)buttonAction:(UIButton *)mybutton{
    for (int i = 0; i < 12; i ++) {
        if ([self.buttonArr objectAtIndex:i] == mybutton) {
            self.buttonNumber = i;
        }
    }
    ClassificationViewController *fk = [[ClassificationViewController alloc] init];
    fk.URLStr = [self.urlArr objectAtIndex:self.buttonNumber];
    [self.navigationController pushViewController:fk animated:NO];
    [fk release];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
